import "default-passive-events";
import { createApp } from "vue";
import App from "./App.vue";
import router from "./router";
import store from "./store";

import hljs from "highlight.js"; //导入代码高亮文件
// import hljsVuePlugin from "@highlightjs/vue-plugin";

const app = createApp(App);

/**
 * noHighlightRe: RegExp
        languageDetectRe: RegExp
        classPrefix: string
        cssSelector: string
        languages?: string[]
        __emitter: EmitterConstructor
        ignoreUnescapedHTML?: boolean
        throwUnescapedHTML?: boolean
 */

hljs.configure({ ignoreUnescapedHTML: true });
app.directive("highlight", function (el) {
  const blocks = el.querySelectorAll("pre code");
  blocks.forEach((block: any) => {
    // block.remove
    block.querySelectorAll("br").forEach((b: any) => b.replaceWith("\n"));
    hljs.highlightElement(block);
  });
});

app.use(router).use(store).mount("#app");
